package com.xm.xmapp.customview;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.xm.xmapp.R;
import com.xm.xmapp.myinterface.MyDialogButton;

public class ShareDialog extends Dialog {

	private MyDialogButton in;

	private Activity activity;

	private LinearLayout[] img = new LinearLayout[5];

	public ShareDialog(Context context, int theme) {
		super(context, theme);
	}

	public ShareDialog(Activity activity, MyDialogButton in) {
		this(activity, R.style.share_Dialog);

		this.activity = activity;
		this.in = in;

	}


	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_share);

		img[0] = (LinearLayout) findViewById(R.id.qq);
		img[1] = (LinearLayout) findViewById(R.id.qzone);
		img[2] = (LinearLayout) findViewById(R.id.sina);
		img[3] = (LinearLayout) findViewById(R.id.wx);
		img[4] = (LinearLayout) findViewById(R.id.wxcircle);

		Window window = getWindow();
		WindowManager.LayoutParams wl = window.getAttributes();
		wl.alpha = 1.0f;

		wl.gravity = Gravity.BOTTOM;
		WindowManager wm = activity.getWindowManager();
		wl.width = wm.getDefaultDisplay().getWidth();
		window.setAttributes(wl);
		setCancelable(true);
		setCanceledOnTouchOutside(true);

		for (int i = 0; i < img.length; i++) {

			final int j = i;

			img[i].setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					dismiss();
					in.setTitle(j, "");
				}
			});

		}

	}

}
